#!/bin/bash

source src/conf/config.conf

cd $tftp_dir
echo " Downloading FreeNAS ..."

    for ARCH in x86 x64; do
        mkdir -p "freenas/${ARCH}"

wget -q -c http://kent.dl.sourceforge.net/project/freenas/FreeNAS-8.3.1/RELEASE-p2/x86/FreeNAS-8.3.1-RELEASE-p2-x86.iso -C freenas/x86/


wget -q -c http://garr.dl.sourceforge.net/project/freenas/FreeNAS-8.3.1/RELEASE-p2/x64/FreeNAS-8.3.1-RELEASE-p2-x64.iso -C freenas/x64


 done

yes | cp -Rv freenas/*  BSD/freenas/

mv freenas/ tars/

    for ARCH in x86 x64; do
        echo "label Install FreeNAS ${ARCH}"
        echo "      menu label FreeNAS ${ARCH}"
        echo "      kernel memdisk"
        echo "      append initrd=BSD/freenas/${ARCH}/initrd.img"
   	echo " append= BSD/freenas/freenas.iso"

echo " "
	echo " TEXT HELP"
       echo "  Install FreeNAS ${ARCH} NAS Server"
        echo " ENDTEXT"


done >> pxelinux.cfg/freenas.cfg


cat >> pxelinux.cfg/bsd << EOF

DEFAULT install
PROMPT 1
TIMEOUT 50 
menu title CentOS Installer
menu include pxelinux.cfg/graphics.conf
MENU BACKGROUND pxelinux.cfg/background.png


MENU BEGIN oses-submenu
 LABEL Previous
        MENU LABEL Previous Menu
        TEXT HELP
        Return to previous menu
        ENDTEXT
        MENU EXIT
 MENU TITLE Install Freenas
MENU INCLUDE pxelinux.cfg/freenas.cfg

MENU END


EOF

